﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.Mvc;

namespace SportStore.WebUI.HtmlHelpers
{
    public static class PagingHelper
    {
        public  static string PageLinks(this HtmlHelper html, int currentPage, int totalPage, Func<int, string> pageUrl)
        {
            StringBuilder result = new StringBuilder();
            for(int i=1; i< totalPage;i++)
            {
                TagBuilder builder = new TagBuilder("a");
                builder.MergeAttribute("href", pageUrl(i));
                builder.InnerHtml = i.ToString();
                if (i== currentPage)
                    builder.AddCssClass("selected");
                result.AppendLine(builder.ToString());
            }
            return result.ToString();
        }
    }
}